<#setting classic_compatible=true> 
<#assign base=request.contextPath />
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8;X-Frame-Options">
	<meta http-equiv="windows-Target" content="top">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- ztree -->
	<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/ztree/demo.css" >
	<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/model.css">
	<#include "/common/commoncss.ftl">
	<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/basicManagement/app.css" > 
    <link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/ztree/zTreeStyle/zTreeStyle.css" >
	<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/bootstrap-table.min.css">
    <title>统一消息中心</title>
</head>
<body class="nav-md">
        <!-- 页面正文部分开始-->
        <div>
				<p id="pid">
					<span class="fa fa-table"></span>
					&nbsp;&nbsp;&nbsp;基础数据&nbsp;&nbsp;<span class="fa fa-angle-right"></span>&nbsp;&nbsp;应用管理
					</p>
			   </div>
			   <div class="container body-content" >
			   		<div id="ztree" style="float:left;width:13%;height:auto">
		                 <ul id="tree" class="ztree"></ul>
		            </div>
					<div class="panel-body" style="float:right;width:85%;background:#ffffff;">
								<form id="formSearch" class="form-horizontal box1"style="padding-bottom: 0px;">
			                   		 <input id="ids" name="id" type="hidden" />
			                         <input id="appTypes" name="appType" type="hidden" />
			                         <div class="form-group col-sm-4"style="padding-left: 0px;padding-right: 0px;width: 330px;margin-bottom: 0px;">
			                            <label for="appCode" class="col-sm-4 control-label"style="padding-left: 0px;padding-right: 0px;width: 70px;">应用编码</label>
		                            	<div class="col-sm-7"style="width: 247px;height: 40px;padding-left: 0px">
			                                <input type="text" class="form-control inputbox" id="appCode" placeholder="请输入应用编码"
			                                  onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')" 
			                                  onpaste="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')" 
			                                  oncontextmenu = "value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')">
			                            </div>
			                         </div>
			                         <div class="form-group col-sm-4 buttons"style="padding-left: 0px;padding-right: 0px;width: 330px;">
			                            <label for="appName" class="col-sm-4 control-label "style="padding-left: 0px;padding-right: 0px;width: 70px;">应用名称</label>
			                            <div class="col-sm-7"style="width: 247px;height: 40px;padding-left: 0px">
			                                <input type="text" class="form-control inputbox" id="appName" placeholder="请输入应用名称"
			                                onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')" 
			                                  onpaste="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')" 
			                                  oncontextmenu = "value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')">
			                            </div>
			                         </div>
			                         <div class="form-group col-sm-4"style="padding-left: 0px;padding-right: 0px;width: 330px;margin-top: 10px;;">
			                            <label for="internetType" class="col-sm-4 control-label "style="padding-left: 0px;padding-right: 0px;width: 70px;">所属网络</label>
			                            <div class="col-sm-7"style="width: 247px;height: 40px;padding-left: 0px;">
			                                <select id="internetType2" name="internetType2" class="form-control inputbox">
			                                </select>
			                           </div>
			                         </div>
 			                          <div class="form-group col-sm-4 buttons" style="padding-left: 0px;padding-right: 0px;width: 66px;height: 40px;margin-top: 10px;">
			                            <div class="col-sm-1"style="padding-left: 0px;width: 66px;height: 40px;padding-right: 0px;">
			                                <button id="btn_query" type="button" class="btn btn-primary two-word-btn"style="background:#00796A;margin-left: 17px;">
			                                	<span class="fa fa-search btn-icon"></span>&nbsp;查询
			                                </button>
			                            </div>
			                         </div> 
			                    </form>
			                    <div id="tool" class="btn-group bs-bars">
			                    	<!--队列接入源应用  -->
				        			<#if param?? && param == "checkOriginApp">
			                			<button type="button" class="btn btn-default" onclick="saveOriginApp()" style="background: #3B9ED9;color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-baocun btn-icon"></span>&nbsp;保存
			                			</button>
		                				<button	type="button" class="btn btn-default" onclick="cancel()" style="background: #32984A; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-chehui btn-icon"></span>&nbsp;取消
			                			</button>
			                			<!--队列接入目标应用  -->
									<#elseif param?? && param == "checkTargetApp">
		                				<button	type="button" class="btn btn-default" onclick="saveTargetApp()" style="background: #3B9ED9; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-baocun btn-icon"></span>&nbsp;保存
			                			</button>
		                				<button	type="button" class="btn btn-default" onclick="cancel()" style="background: #32984A; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-chehui btn-icon"></span>&nbsp;取消
			                			</button>

			                			<!--服务接入源应用  -->

			            			<#elseif param?? && param == "unprocessedApp">
		                				<button	type="button" class="btn btn-default" onclick="saveUnprocessedApp()" style="background: #3B9ED9; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-baocun btn-icon"></span>&nbsp;保存
			                			</button>
		                				<button	type="button" class="btn btn-default" onclick="cancel1()" style="background: #32984A; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-chehui btn-icon"></span>&nbsp;取消
			                			</button>
			                			<!--服务接入目标应用  -->  
			                		<#elseif param?? && param=="TargetApp"> 
			                			<button	type="button" class="btn btn-default" onclick="saveTargetAppOne()" style="background: #3B9ED9; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-baocun btn-icon"></span>&nbsp;保存
			                			</button>
		                				<button	type="button" class="btn btn-default" onclick="cancel1()" style="background: #32984A; color: #fff;width:66px;height:40px;padding-left:0px;padding-right:0px;">
		                    				<span class="IconFont icon-chehui btn-icon"></span>&nbsp;取消
			                			</button> 
									<#else>
										<button style="color: #ffffff;background: #3B9ED9;width:66px;height:40px;padding-left:0px;padding-right:0px;"type="button" class="btn btn-default" onclick="addMap()">
			                    			<span class="IconFont icon-add btn-icon" aria-hidden="true"></span>&nbsp;新增
			                			</button>
			                			<button  style="color: #ffffff;background: #7ABD3E;width:66px;height:40px;padding-left:0px;padding-right:0px;"type="button" class="btn btn-default" onclick="modify()">
			                    			<span class="IconFont icon-edit-1-copy btn-icon" aria-hidden="true"></span>&nbsp;修改
			                			</button>
			                			<button  style="color: #ffffff;background: #6F7ABA;width:104px;height:40px;padding-left:0px;padding-right:0px;"type="button"class="btn btn-default" onclick="keyreset()">
			                    			<span class="IconFont  icon-zhongzhimima btn-icon" aria-hidden="true"></span>&nbsp;密钥重置
			                			</button>
			                			<button  style="color: #ffffff;background: #38924D;width:104px;height:40px;padding-left:0px;padding-right:0px;"type="button" class="btn btn-default" onclick="servicekey()">
		                      				<span class="fa fa-eye" aria-hidden="true"></span>&nbsp;查看密钥
		               		 			</button>
			                			<button  style="color: #ffffff;background: #FFA45A;width:66px;height:40px;padding-left:0px;padding-right:0px;"type="button" class="btn btn-default" onclick="delAll()">
		                      				<span class="IconFont icon-shanchu btn-icon" aria-hidden="true"></span>&nbsp;删除
		               		 			</button>
									</#if>
									
						</div>
							<table id="tb_app"  class="table table-hover"></table>
					  </div>
					</div>

<!-- 新增  -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header" style="padding:8px">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">
                            	新增
                        </h4>
                    </div>
                    <div id="" class="modal-body"style="text-align: center;">
                        <form id="myform" class=" form-horizontal">
                        </form>
		                <button type="button" id="saveAdd"class="btn btn-primary saves" style="background: #3B9ED9;"onclick="add()">保存
		                </button>
		                <button type="reset" id="saveRever"class="btn btn-primary call"  style="background: #6F7ABA;"onclick="empty()" >重置
		                </button>
		               <button type="button" id="saveback"class="btn btn-primary backs"   style="background: #38924D;" data-dismiss="modal">返回
		               </button>
		             </div>
                </div>
            </div>
        </div>
     <!-- 修改框 -->
     <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header" style="padding:8px">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">
                            	修改
                        </h4>
                    </div>
                    <div id="" class="modal-body"style="text-align: center;">
                        <form id="myform2" class=" form-horizontal">
                        </form>
		                <button type="button" id="updatesave"class="btn btn-primary saves" style="background: #3B9ED9;" onclick="save()">保存
		                </button>
		               <button type="button" id="updateback"class="btn btn-default backs" style="background: #38924D;color:#ffffff;"data-dismiss="modal">返回
		               </button>
		            </div>
                </div>
            </div>
        </div>   

    <!--服务密钥-->
        <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3"
             aria-hidden="true">
            <div class="modal-dialog" >
                <div class="modal-content">
                    <div class="modal-header" style="padding:8px">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel3">
                            	密钥
                        </h4>
                    </div>
                    <div id="" class="modal-body">
                        <form id="myform3" class=" form-horizontal">
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!-- 队列密钥 -->
         <div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel4"
             aria-hidden="true">
            <div class="modal-dialog" style="width:20%">
                <div class="modal-content">
                    <div class="modal-header" style="padding:8px">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel4">
                            	队列密钥
                        </h4>
                    </div>
                    <div id="" class="modal-body">
                        <form id="myform4" class=" form-horizontal">
                        </form>
                    </div>
                </div>
            </div>
        </div>
<!-- 修改时时应用的分类 -->
<script id="appTypeTemplate" type="text/html">
			<%if(list==null||list==""){%>	
				<option value>全部</option>
			<%}%>
   	   	    <%for(var i = 0; i < app.length; i++) {%>
				   <%if(list!=null&&list!=""){%>
						<%if(list.appType==app[i].dictCode){%>
    						<option value="<%:=app[i].dictCode%>"selected><%:=app[i].dictName%></option>
						<%}else{%>
							<option value="<%:=app[i].dictCode%>"><%:=app[i].dictName%></option>
						<%}%>
					<%}else{%>
						<option value="<%:=app[i].dictCode%>"><%:=app[i].dictName%></option>
					<%}%>
   	  		 <%}%>
</script>


<!-- 服务密钥 -->
<script id="servicekeyTemplate" type="text/html">
    <div class="form-group">
        <label for="key" class="col-sm-2" style="width: 50%;">服务密钥 (用于服务接入):</label>
		<button type="button" class="btn btn-default" onclick="download()"style="background: #3B9ED9;color: #ffffff;width:66px;height:40px;border:0px;">下载</button>
    </div>
	<div style="height:10px"></div>
    <div class="form-group">
        <label for="key" class="col-sm-2" style="width: 50%;">队列密钥 (用于消息队列接入):</label>
	   <button type="button" class="btn btn-default" onclick="downloadKey()"style="background: #3B9ED9;color: #ffffff;width:66px;height:40px;border:0px;">下载</button>
    </div>
</script>
<!-- 修改时的网络状态(外网/内网) -->
<script id="internetTypeTemplate" type="text/html">
	<%if(list==""||list==null){%>
		<option  value="" selected>全部</option>
	<%}%>
    <%for(var i = 0; i < app.length; i++) {%>
		<%if(list!=""&&list!=null){%>
			<%if (list.internetType==app[i].internetType){%>
				<option value="<%:=app[i].internetType%>"selected><%:=app[i].internetName%></option>
			<%}else{%>
				<option value="<%:=app[i].internetType%>"><%:=app[i].internetName%></option>
			<%}%>    	
    	<%}else{%>
				<option value="<%:=app[i].internetType%>"><%:=app[i].internetName%></option>
		<%}%>
	<%}%>
</script>
<!-- 新增修改的模板 -->
<script id="myFormTemplate" type="text/html">
	<%if(app.id!=""&&app.id!=null){%>
 		<input id="id" type="hidden" name="id" value="<%:=app.id%>"/>
	<%}%>
    <div class="form-group">
        <label for="appCode" class="col-sm-2 mylabel control-label"style="width: 19%;"> 应用编码:</label>
        <div class="col-sm-4 col-sm-me">
			<%if(app.appCode!=""&&app.appCode!=null){%>
            	<input  type="text" class="form-control radius" name="appCode" 
                  	 value="<%:=app.appCode%>"readonly="readonly">
			<%}else{%>
				<input  type="text" class="form-control radius" name="appCode" placeholder="请输入应用编码" maxlength=32" 
                  	readonly="readonly">
			<%}%>
        </div>
	</div>
	<div class="form-group">
        <label for="appName" class="col-sm-2 mylabel control-label"style="width: 19%;">应用名称:</label>
        <div class="col-sm-4 col-sm-me">
		<%if(app.appName!=""&&app.appName!=null){%>
            <input type="text" class="form-control radius" name="appName" placeholder="请输入应用名称" maxlength="32" onkeyup="this.value=this.value.replace(/^ +| +$/g, '')"
                   value="<%:=app.appName%>">
		<%}else{%>
			<input type="text" class="form-control radius" name="appName" placeholder="请输入应用名称" maxlength="32" onkeyup="this.value=this.value.replace(/^ +| +$/g, '')">
		<%}%>
        </div>
    </div>
	<div class="form-group">
        <label for="appType" class="col-sm-2 mylabel control-label"style="width: 19%;">应用类型:</label>
        <div class="col-sm-4 col-sm-me">
            	<select id="appType"name="appType"class="form-control radius">
				</select>
        </div>
    </div>
	<div class="form-group">
        <label for="internetType" class="col-sm-2 mylabel control-label"style="width: 19%;">所属网络:</label>
        <div class="col-sm-4 col-sm-me">
            	<select id="internetType"name="internetType"class="form-control radius">
				</select> 
        </div>
    </div>
    <div class="form-group">
        <label for="principal" class="col-sm-2 mylabel control-label"style="width: 19%;">负责人:</label>
        <div class="col-sm-4 col-sm-me">
		<%if(app.principal!=""&&app.principal!=null){%>
            <input type="text" class="form-control radius" name="principal" placeholder="请输入联系人" maxlength="32"
                   value="<%:=app.principal%>" onkeyup="this.value=this.value.replace(/^ +| +$/g, '')">
		<%}else{%>
            <input type="text" class="form-control radius" name="principal" placeholder="请输入联系人" maxlength="32"
			onkeyup="this.value=this.value.replace(/^ +| +$/g, '')">
		<%}%>
        </div>
	</div>
	<div class="form-group">
        <label for="principalContact" class="col-sm-2 mylabel control-label"style="width: 19%;">联系方式:</label>
        <div class="col-sm-4 col-sm-me">
			<%if(app.principalContact!=""&&app.principalContact!=null){%>
           		<input type="text" class="form-control radius" name="principalContact" placeholder="请输入联系方式" maxlength="17"
                  	 value="<%:=app.principalContact%>">
			<%}else{%>
				<input type="text" class="form-control radius" name="principalContact" placeholder="请输入联系方式" maxlength="17"
                 >
			<%}%>
        </div>
    </div>
</script>
<!-- 引入通用和js -->
<#include "/common/commonjs.ftl">  
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/basicManagement/app.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/template.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/jquery.serializejson.min.js"></script>
<!-- ztree -->
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/ztree/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/ztree/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/ztree/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/ztree/jquery.ztree.exhide.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/echarts.js"></script>
<script type="text/javascript">
var param = "${param!}";

//var tarId = "${targetId!''}";
//console.log("更换的目标应用id: " , tarId);

var index = "${index!''}";

var tId = "${tId!''}";
//console.log("消息队列主键id: ", tId);

//console.log("参数: ", param );
var key = "${key!}";
var num = "${num!}";
//console.log("key值: ", key );
//消息队列接入的url
/* var url = "${url!}";
//console.log("消息队列接入的url: ", url);
 */

var keyId;
var internetType;
var appType;
    $(function () {
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
        $("#btn_query").click(function () {
          $('#tb_app').bootstrapTable('refreshOptions',{pageNumber:1});
           $('#tb_app').bootstrapTable('refresh');
        });
        $.ajax({
        	url:"/zhgl-jzstyxx-manage/application/selectByAppType",
            type: 'post',
        	dataType: 'json',
        	success: function (data) {
        		    appType=data;  
        	}
        });
    	//网络状态（外网/内网）
    	$.getJSON("/zhgl-jzstyxx-manage/application/selectByInternetType", function (data) {
    		internetType=data;
	        var tpl = document.getElementById('internetTypeTemplate').innerHTML;
	        var html = template(tpl, {app: internetType,list:""});
	        $("select[name='internetType2']").html(html);
	    });
    });
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#tb_app').bootstrapTable({
                url:'/zhgl-jzstyxx-manage/application/getPage',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                toolbar: '#toolbar',                //工具按钮用哪个容器
                dataType: 'json',
                singleSelect: false,               //false是为多选。true为单选
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oTableInit.queryParams,//传递参数（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 20 ,30],      //可供选择的每页的行数（*）
                strictSearch: true,
                clickToSelect: true,                //是否启用点击选中行
		     // height: 1000,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                cardView: false,                    //是否显示详细视图
              //detailView: false,                   //是否显示父子表
                rowStyle: function rowStyle(row, index) {
                    return {
                        css: {"font-size": "14px", "height": "40px", "line-height": 1,"color":"#666666 !important"}
                    };
                },
                columns: [
                     {
                        checkbox: true
                     },
                     {
         				field : 'id',
         				title : '序号',
         				align : 'center',
         				formatter : function(value, row, index) {
         					var pageSize=$('#tb_app').bootstrapTable('getOptions').pageSize;//通过表的#id可以得到每页多少条
                 			var pageNumber=$('#tb_app').bootstrapTable('getOptions').pageNumber;//通过表的#id可以得到当前第几页
         					return pageSize*(pageNumber-1)+index+1;
         				}
         			},
                     {
                   		 field: 'appCode',
                   		 title: '应用编码',
                   		 align: 'left',
               		 },
               		 {
               			field: 'appName',
                        title: '应用名称',
                        align: 'left',
                     },
                     {
                  	field:'internetName',
                  	title:'网络状态',
                   	width:'15%',
                   	align:'left',
                    }, 
                     {
                     	field:'principal',
                     	title:'负责人',
                      	align:'left',
                      },
                     {
                    	 field:'principalContact',
                    	 title:'联系方式',
                  		 align:'left',
                     },
                 ]
             });
         };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
        	//选择时应用启用状态 1002 
        	var statusValue = $("#status").val();
        	if(param) {
        		statusValue = 1002
        	}
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit       : params.limit,   //页面大小
                offset      : params.offset,  //页码
                appCode     : $("#appCode").val(),
                appName     : $("#appName").val(),
                internetType: $("#internetType2").val(),
                appType     : $("#appTypes").val(),
                id          : $("#ids").val()
           	 };
            return temp;
        };
        return oTableInit;
    }
</script>
</body>
</html>
